$(function(){
	/*function isIE() {
	    if (!!window.ActiveXObject || "ActiveXObject" in window){
	        return true;
	     }else{         
	     	return false;    
	     }
	}
	if(isIE()){
		$(".footerTitle").last().css("width","27%");
	}*/

	$.ajax({
		type:"get",
		url:"/Home/index",
		success:function(data){
			show(data);
		}
	});
	var companyInfoHtml = '';
	function show(data){
		console.log(data)
		// for(var i=0;i<data.data.arts.length;i++){
		// 	companyInfoHtml+='<li class="col-md-12 found" aid="'+data.data.arts[i].aid+'"><a href="/home/index/art/aid/'+data.data.arts[i].aid+'/new/1"><span '+addWidth(i)+'></span><span></span><span>'+data.data.arts[i].ymd+'</span><span>'+cutstr(data.data.arts[i].title, 35)+'</span><span>>></span></a></li>'
		// }
		// $(".companyInfo").html(companyInfoHtml);
		var num = 1;
	var width = $($('.found').find('span')[0]).width();
	var bgI = ["images/titleImg3.jpg","images/titleImg2.jpg","images/titleImg1.jpg","images/titleImg3.jpg","images/titleImg1.jpg","images/titleImg2.jpg"];//首页banner背景图
	var padding = 30;
//	var bgI = ["images/banner1.jpg","images/banner2.jpg","images/banner1.jpg","images/banner2.jpg","images/banner1.jpg","images/banner2.jpg"];
	var newsImg = ["images/media1.jpg","images/media2.jpg","images/media3.jpg"];
	var newsText = [];
	var  newsDate = ["用文字记录向荣故事","用镜头捕捉向荣瞬间","用媒体见证向荣成长"];
	var newsTitle = ["向荣故事","向荣视频","向荣报道"];
	var friendImg = ["images/1.png","images/2.png","images/3.png","images/4.png","images/5.png","images/6.png","images/7.png","images/8.jpg","images/9.jpg"];//合作伙伴背景图
//	var friendImg = ["images/1.png","images/2.png","images/3.png","images/4.png","images/5.png","images/6.png","images/7.png"];
	var mediaHref = ["/Home/Index/xin/cid/4","/Home/Index/xin/cid/5","/Home/Index/xin/cid/6"]
	//故事报道视频内容添加
//	for(var i=0;i<data.data.list.length;i++){
//		newsImg.push(data.data.list[i].pic1);
//		newsText.push(cutstr(data.data.list[i].content, 250));
//		newsDate.push(data.data.list[i].ymd)
//	}
		//bannerr图的宽高变化
	$('.banner,.about,.mission-gd,.simple,.capabilities,.service-grid,.bannerSix,.bannerSix div').css({
			"width" : $(window).width(),
			"height" : $(window).height()
	});
	
		$('.bannerSix div').each(function(i,e){
			
			$(e).css({
				"background":"url("+bgI[i]+") no-repeat",
				"background-size" : "100% 100%",
				"opacity" : "0",
				}
			)
	});
	$($('.bannerSix div')[0]).css({
			"background":"url("+bgI[0]+") no-repeat",
			"background-size" : "100% 100%",
			"opacity" : "1",
		})

		//bannerr图的宽高变化
		$('.container,.logo-text').css({
				"height": "100%"
			});
		$(window).resize(function(){
			$('.banner,.about,.mission-gd,.simple,.capabilities,.service-grid,.bannerSix,.bannerSix div').css({
				"width" : $(window).width(),
				"height" : $(window).height()
			});
			$('.logo-text a').css({
				"height": "50%"
			});
			$('.container,.logo-text').css({
				"height": "100%"
			});
			// $('.banner-info').css({
			// 	"height": "100%"
			// });
			$('.report ul li div').css("lineHeight",$('.report ul li div').height()+"px");
		});
	
	
		//合作伙伴
		var friendHtml = '';
		var xinzengHtml = '';
		for(var i=0;i<friendImg.length-2;i++){
			friendHtml+='<li style="float: left;"><img src="'+friendImg[i]+'" /></li>';
		}
		for(var i=friendImg.length-2;i<friendImg.length;i++){
			xinzengHtml+='<img src="'+friendImg[i]+'" />';
		}
		$(".xinzeng").html(xinzengHtml);
		$('.friend ul').html(friendHtml);
	
		//项目上滑背景
		$('.mission-gd ul li').css({"paddingTop":"19.791%"})
		$('.mission-gd ul li').mouseover(function(){
			$(this).stop(false).animate({"padding-Top": "19%"},200,"linear");
			$(this).find('div').stop(false).animate({"bottom":"0"},200,"linear");
			return false;
		});
		$('.mission-gd ul li').mouseout(function(){
			$(this).stop(false).animate({"padding-Top": "19.791%"},200,"linear");
			$(this).find('div').stop(false).animate({"bottom":"-100%"},200,"linear");
			return false;
		})
		//欣悦成长
		$('.found').mouseover(function(){
	//		$($(this).find('span')[0]).stop(true,false).animate({width:width+150},100,"linear")
			$($(this).find('span')[0]).css({"borderColor":"#403c91"});
			$($(this).find('span')[1]).css("backgroundColor","#403c91");
			$($(this).find('span')[2]).css("color","#403c91");
			$($(this).find('span')[3]).css("color","#fefefe");
			$($(this).find('span')[4]).css("color","#403c91");
			return false;
			
		});
		$('.found').mouseout(function(){
		
//			$($(this).find('span')[0]).stop(true,false).animate({width:width},100,"linear")
				$($(this).find('span')[0]).css({"borderColor":"#fbc902"})
				$($(this).find('span')[1]).css("backgroundColor","#fbc902");
				$($(this).find('span')[2]).css("color","#fbc902");
				$($(this).find('span')[3]).css("color","#1e1e1e");
				$($(this).find('span')[4]).css("color","#fbc902");
				return false;
		});
		//
	
		//报告
		$('.report ul li').mouseover(function(){
			$(this).css({
				"background":"#403c91",
				"color": "#fff",
				"borderColor": "#403c91"
			});
			$(this).find('span').show();
		});
		$('.report ul li').mouseout(function(){
			$(this).css({
				"background":"rgba(255,255,255,.2)",
				"color": "#000",
				"borderColor": "#8d8b8b"
			});
			$(this).find('span').hide();
		});
	
		//新闻切换
	
		var newsNum = 0;
		news();
		$('.newsTab').click(function(){
			newsNum++;
			if(newsNum>newsImg.length-1) newsNum = 0;
			news();
		});
		//小圆点
		var dotHtml = '';
		for(var i=0;i<newsText.length;i++){
			dotHtml+='<span class="dotList" style="margin-right:40px"></span>';
		}
		$('.dot').html(dotHtml)
		$($('.dotList')[newsNum]).css("background","rgba(255,255,255,.8)");
		$('.dotList').mouseover(function(){
			newsNum = $(this).index();
			news();
		})
		function news(){
			$(".news").css({
				"background" : "url("+newsImg[newsNum]+") no-repeat",
				"backgroundSize": "100% 91%",
			    "-webkit-background-size": "100% 91%",
			    "-o-background-size": "100% 91%",
			    "-ms-background-size": "100% 91%",
			    "-moz-background-size": "100% 91%"
			});
			$('.newsDate').html(newsDate[newsNum]);
	//		$('.newsText').html(newsText[newsNum]);
			$('.newsContentTitle').html(newsTitle[newsNum]);
			$('.dotList').css("background","rgba(255,255,255,.5)")
			$($('.dotList')[newsNum]).css("background","rgba(255,255,255,.8)");
			$(".mediaHref").attr("href",mediaHref[newsNum]);
		}
	
	    //新闻节点跳转详细信息
	    $(".found").click(function(){
	    	window.localStorage.setItem("n",$(this).index());
	    	window.localStorage.setItem("aid",$(this).attr("aid"));
	    })
	}
	//增加宽度
	function addWidth(i){
		if(i==1||i==3){
			return "style='width: 22.010417%;'"
		}
	}
	//限制超出字符以省略号显示
	function cutstr(str, len) {
		var str_length = 0;
		var str_len = 0;
		str_cut = new String();
		str_len = str.length;
		for (var i = 0; i < str_len; i++) {
			a = str.charAt(i);
			str_length++;
			if (escape(a).length > 4) {
				//中文字符的长度经编码之后大于4
				str_length++;
			}
			str_cut = str_cut.concat(a);
			if (str_length >= len) {
				str_cut = str_cut.concat("...");
				return str_cut;
			}
		}
		//如果给定字符串小于指定长度，则返回源字符串；
		if (str_length < len) {
			return str;
		}
	}
//	var onOff = true;
	
})
